<template>
  <div>
    <!-- 标题 -->
    <van-cell title="搜索历史">
      <van-icon name="delete-o" @click="isDel = true" v-if="!isDel" />
      <div v-else>
        <span @click="$store.commit('SET_HISTORIES,[]')">全部删除</span> &nbsp;
        <span @click="isDel = false">完成</span>
      </div>
    </van-cell>

    <!-- 搜索历史 -->
    <van-cell v-for="item in $store.state.histories" 
    :key="item" 
    :title="item"
    @click="$emit('update-keywords', item)"
    >
      <van-icon
       name="close"
        v-if="isDel"
        @click="
        $store.commit(
            'SET_HISTORIES',
            $store.state.histories.filter((i) = i !== item)
        )
         
        "
        />
    </van-cell>
  </div>
</template>

<script>
export default {
    data() {
        return {
        isDel: false,
    }
  }
};
</script>

<style>
</style>